<?php
/**
 * User: itimphp
 * Date: 6/6/12
 * Time: 9:57 PM
 */
require_once 'bootstrap.php';
$multichoice = Service_Value::get_multilchoice(2);
?>

<head xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
	<link href="css/bootstrap.css" type="text/css" rel="stylesheet">
	<link href="css/bootstrap-responsive.css" type="text/css" rel="stylesheet">
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/bootstrap.js"></script>
	<script type="text/javascript" src="js/bootstrap.datetimepicker.js"></script>
	<title>Loan form - Form 2</title>
</head>
<html>
<body style="background-color:#000;">
<script type="text/javascript">
	var RecaptchaOptions = {
		theme:'white'
	};
</script>
<div style="background-color:#E9E9E9; width: 700px; margin-left: auto; margin-right: auto;">
<h2>Loan Form 2</h2>

<form class="form-inline form-horizontal" method="POST" action="form2.php" onsubmit="return validate();" id="form2">
<div class="control-group">
	<label class="control-label" for="loan_amount">Loan Amount</label>

	<div class="controls">
		<select name="loan_amount" id="loan_amount" class="require">
			<option value="">Please select</option>
			<?php foreach ($multichoice['loan_amount'] as $key => $value): ?>
			<option value="<?= $key ?>"><?= $value ?></option>
			<?php endforeach;?>
		</select>
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="purpose">Purpose of Loan</label>

	<div class="controls">
		<select name="purpose" id="purpose" class="require">
			<option value="">Please select</option>
			<?php foreach ($multichoice['purpose'] as $key => $value): ?>
			<option value="<?= $key ?>"><?= $value ?></option>
			<?php endforeach;?>
		</select>
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="repayment_period">Repayment Period</label>

	<div class="controls">
		<select name="repayment_period" id="repayment_period" class="require">
			<option value="">Please select</option>
			<?php for ($i = 1; $i <= 9; $i++): ?>
			<option value="<?= ($i * 6) ?>"><?php echo ($i == 7) ? 'More than 48 ' : ($i * 6) ?> Months</option>
			<?php endfor;?>
		</select>
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="credit_rating">Credit Rating</label>

	<div class="controls">
		<select name="credit_rating" id="credit_rating" class="require">
			<option value="">Please select</option>
			<?php foreach ($multichoice['credit_rating'] as $key => $value): ?>
			<option value="<?= $key ?>"><?= $value ?></option>
			<?php endforeach;?>
		</select>
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="title">Title</label>

	<div class="controls">
		<select name="title" id="title" class="require">
			<option value="">Please select</option>
			<?php foreach ($multichoice['title'] as $key => $value): ?>
			<option value="<?= $key ?>"><?= $value ?></option>
			<?php endforeach;?>
		</select>
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="first_name">First name</label>

	<div class="controls">
		<input type="text" id="first_name" name="first_name" class="span3 require" maxlength="255">
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="last_name">Last name</label>

	<div class="controls">
		<input type="text" id="last_name" name="last_name" class="span3 require" maxlength="255">
	</div>
</div>
<div class="control-group">
	<label class="control-label">Date of birth</label>

	<div class="controls">
		<select name="birth_date_day" id="birth_date_day" class="require">
			<option value="">Day...</option>
			<?php for ($i = 1; $i <= 31; $i++): ?>
			<option value="<?= $i ?>"><? echo $i;?></option>
			<?php endfor;?>
		</select>
		<select name="birth_date_month" id="birth_date_month" class="require">
			<option value="">Month...</option>
			<?php for ($i = 1; $i <= 12; $i++): ?>
			<option value="<?= $i ?>"><? echo $i;?></option>
			<?php endfor;?>
		</select>
		<select name="birth_date_year" id="birth_date_year" class="require">
			<option value="">Year...</option>
			<?php for ($i = 2012; $i > 1940; $i--): ?>
			<option value="<?= $i ?>"><? echo $i;?></option>
			<?php endfor;?>
		</select>
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="email">Email</label>

	<div class="controls">
		<input type="text" id="email" name="email" class="span3 require" maxlength="255">
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="home_phone">Home phone</label>

	<div class="controls">
		<input type="text" id="home_phone" name="home_phone" class="span3">
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="mobile_phone">Mobile phone</label>

	<div class="controls">
		<input type="text" id="mobile_phone" name="mobile_phone" class="span3 require">
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="title">Time to Contact</label>

	<div class="controls">
		<select name="time_to_contact" id="time_to_contact" class="require">
			<option value="">Please select</option>
			<?php foreach ($multichoice['time_to_contact'] as $key => $value): ?>
			<option value="<?= $key ?>"><?= $value ?></option>
			<?php endforeach;?>
		</select>
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="title">Country of Residence</label>

	<div class="controls">
		<select name="country_of_residence" id="country_of_residence" class="require">
			<option value="">Please select</option>
			<?php foreach ($multichoice['country_of_residence'] as $key => $value): ?>
			<option value="<?= $key ?>"><?= $value ?></option>
			<?php endforeach;?>
		</select>
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="title">Status</label>

	<div class="controls">
		<select name="married_status" id="married_status" class="require">
			<option value="">Please select</option>
			<?php foreach ($multichoice['married_status'] as $key => $value): ?>
			<option value="<?= $key ?>"><?= $value ?></option>
			<?php endforeach;?>
		</select>
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="house_number">House Number</label>

	<div class="controls">
		<input type="text" id="house_number" name="house_number" class="span3 require">
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="house_name">House/Flat name</label>

	<div class="controls">
		<input type="text" id="house_name" name="house_name" class="span3 require">
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="street">Street name</label>

	<div class="controls">
		<input type="text" id="street" name="street" class="span3 require" maxlength="255">
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="area">Area</label>

	<div class="controls">
		<input type="text" id="area" name="area" class="span3 require" maxlength="255">
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="town">Town</label>

	<div class="controls">
		<input type="text" id="town" name="town" class="span3 require" maxlength="255">
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="country">County</label>

	<div class="controls">
		<input type="text" id="country" name="country" class="span3 require" maxlength="255">
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="postcode">Postcode</label>

	<div class="controls">
		<input type="text" id="postcode" name="postcode" class="span3 require" maxlength="255">
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="residential_status">Residential Status</label>

	<div class="controls">
		<select name="residential_status" id="residential_status" class="require">
			<option value="">Please select</option>
			<?php foreach ($multichoice['residential_status'] as $key => $value): ?>
			<option value="<?= $key ?>"><?= $value ?></option>
			<?php endforeach;?>
		</select>
	</div>
</div>
<div class="control-group">
	<label class="control-label">Have you lived at this address for 3 or more years?</label>

	<div class="controls">
		<label class="radio">
			<input type="radio" value="2" name="time_at_home" class="require">
			<span class="help-inline">Yes</span>
		</label>
		<label class="radio inline">
			<input type="radio" value="1" name="time_at_home" class="require">
			<span class="help-inline">No</span>
		</label>
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="employment_type">Employment Status</label>

	<div class="controls">
		<select name="employment_type" id="employment_type" class="require">
			<option value="">Please select</option>
			<?php foreach ($multichoice['employment_type'] as $key => $value): ?>
			<option value="<?= $key ?>"><?= $value ?></option>
			<?php endforeach;?>
		</select>
	</div>
</div>
<div class="control-group">
	<label class="control-label" for="frequency_income">Annual Income</label>

	<div class="controls">
		<input type="text" id="frequency_income" name="frequency_income" class="span3 require" maxlength="255">
	</div>
</div>
<div class="control-group">
	<label class="control-label">Are your wages paid directly into your bank account?</label>

	<div class="controls">
		<label class="radio">
			<input type="radio" value="2" name="salary_to_bank">
			<span class="help-inline">Yes</span>
		</label>
		<label class="radio inline">
			<input type="radio" value="1" name="salary_to_bank">
			<span class="help-inline">No</span>
		</label>
	</div>
</div>
<div class="control-group">
	<label class="control-label">Have you ever been in a debt management programme?</label>

	<div class="controls">
		<label class="radio">
			<input type="radio" value="2" name="debt">
			<span class="help-inline">Yes</span>
		</label>
		<label class="radio inline">
			<input type="radio" value="1" name="debt">
			<span class="help-inline">No</span>
		</label>
	</div>
</div>
<div class="control-group">
	<label class="control-label">If required, could you get a guarantor for the loan?</label>

	<div class="controls">
		<label class="radio">
			<input type="radio" value="2" name="guarantor">
			<span class="help-inline">Yes</span>
		</label>
		<label class="radio inline">
			<input type="radio" value="1" name="guarantor">
			<span class="help-inline">No</span>
		</label>
	</div>
</div>
<div class="control-group">
	<label class="control-label">Have you ever been declared bankrupt?</label>

	<div class="controls">
		<label class="radio">
			<input type="radio" value="2" name="bankrupt">
			<span class="help-inline">Yes</span>
		</label>
		<label class="radio inline">
			<input type="radio" value="1" name="bankrupt">
			<span class="help-inline">No</span>
		</label>
	</div>
</div>

<div class="control-group">
	<div class="controls">
		<label class="checkbox">
			<input type="checkbox" value="1" name="agr1" id="need">
			<span class="help-inline">I accept all <a href="#">Terms and Conditions</a></span>
		</label>
	</div>
</div>
<div class="control-group">
	<label class="control-label">Type the words</label>

	<div class="controls">
		<?php
		$publickey = '6LdkS9ISAAAAAAiOzrgYDSbCgcd9Fw4rutkulGQq'; // you got this from the signup page
		echo recaptcha_get_html($publickey);
		?>
	</div>
</div>
<div class="control-group">
	<div class="controls">
		<input type="submit" value="Submit">
	</div>
</form>
</div>
</body>
<script type="text/javascript">
	function validate() {
		if (!$("#need").is(":checked")) {
			$("#need").parent().parent().parent().addClass("error");
			$("#need").focus();
			return false;
		} else {
			$("#need").parent().parent().parent().removeClass("error");
		}
		var ok = true;
		$(".require").each(function () {
			if ($(this).val() == "") {
				$(this).parent().parent().addClass("error");
				ok = false;
			} else {
				$(this).parent().parent().removeClass("error");
			}
		});
		if (!$("input[name='time_at_home']:checked").val()) {
			$("input[name='time_at_home']").parent().parent().parent().addClass("error");
			ok = false;
		}
		else {
			$("input[name='time_at_home']").parent().parent().parent().removeClass("error");
		}
		if (!$("input[name='salary_to_bank']:checked").val()) {
			$("input[name='salary_to_bank']").parent().parent().parent().addClass("error");
			ok = false;
		}
		else {
			$("input[name='salary_to_bank']").parent().parent().parent().removeClass("error");
		}
		if (!$("input[name='debt']:checked").val()) {
			$("input[name='debt']").parent().parent().parent().addClass("error");
			ok = false;
		}
		else {
			$("input[name='debt']").parent().parent().parent().removeClass("error");
		}
		if (!$("input[name='guarantor']:checked").val()) {
			$("input[name='guarantor']").parent().parent().parent().addClass("error");
			ok = false;
		}
		else {
			$("input[name='guarantor']").parent().parent().parent().removeClass("error");
		}
		if (!$("input[name='bankrupt']:checked").val()) {
			$("input[name='bankrupt']").parent().parent().parent().addClass("error");
			ok = false;
		}
		else {
			$("input[name='bankrupt']").parent().parent().parent().removeClass("error");
		}
		/*
		  $("#form2").find("input[type=radio]").each(function () {
			  alert($(this).val());
			  if ($(this).val()>0 != 'undefine' && $(this).val()>0){
				  $(this).parent().parent().parent().removeClass("error");
			  } else {
				  $(this).parent().parent().parent().addClass("error");
				  ok = false;
			  }
		  });
  */
		if (!ok) {
			$(".alert-error").remove();
			$("#form2").prepend('<div class="alert alert-error">Please fill full information</div>');
		} else {
			$(".alert-error").remove();
		}
		return ok;
	}
</script>
</html>